﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyCHTrangSuc
{
    public partial class ItemUC : UserControl
    {
        #region Atrributes
        PictureBox _picture = new PictureBox();
        Label _label1 = new Label();
        Label _label2 = new Label();
        #endregion

        #region Properties
        public PictureBox Picture
        {
            get { return _picture; }
            set { _picture = value; }
        }
        public Label Label1
        {
            get { return _label1; }
            set { _label1 = value; }
        }
        public Label Label2
        {
            get { return _label2; }
            set { _label2 = value; }
        }
        #endregion

        public ItemUC()
        {
            InitializeComponent();
            _picture.Size = new Size(this.Height * 2 / 3, this.Width * 2 / 3);
            _picture.Location = new Point(this.Width / 2 - _picture.Width / 2, 0);
            _picture.Click += new EventHandler(subItem_Click);
            _picture.MouseDown += new MouseEventHandler(subItem_MouseDown);
            this.Controls.Add(_picture);
            _label1.AutoSize = false;
            _label1.Size = new Size(this.Width * 19 / 25, this.Height / 5);
            _label1.Location = new Point(this.Width / 2 - _label1.Width / 2, this.Height * 17 / 25);
            _label1.Font = new Font("Arial", 8.5F);
            _label1.TextAlign = ContentAlignment.TopCenter;
            _label1.Click += new EventHandler(subItem_Click);
            _label1.MouseDown += new MouseEventHandler(subItem_MouseDown);
            this.Controls.Add(_label1);
            _label2.AutoSize = false;
            _label2.Size = new Size(this.Width, this.Height * 7 / 75);
            _label2.Location = new Point(0, this.Height * 67 / 75);
            _label2.ForeColor = Color.Red;
            _label2.TextAlign = ContentAlignment.TopCenter;
            _label2.Click += new EventHandler(subItem_Click);
            _label2.MouseDown += new MouseEventHandler(subItem_MouseDown);
            this.Controls.Add(_label2);
        }

        void subItem_Click(object sender, EventArgs e)
        {
            this.OnClick(e);
        }

        void subItem_MouseDown(object sender, MouseEventArgs e)
        {
            this.OnMouseDown(e);
        }

        private void ItemUC_Load(object sender, EventArgs e)
        {
            XL_DO_HOA.SetImage(_picture);
        }

        private void ItemUC_Resize(object sender, EventArgs e)
        {
            _picture.Size = new Size(this.Height * 2 / 3, this.Width * 2 / 3);
            _picture.Location = new Point(this.Width / 2 - _picture.Width / 2, 0);
            _label1.Size = new Size(this.Width * 19 / 25, this.Height / 5);
            _label1.Location = new Point(this.Width / 2 - _label1.Width / 2, this.Height * 17 / 25);
            _label2.Size = new Size(this.Width, this.Height * 7 / 75);
            _label2.Location = new Point(0, this.Height * 67 / 75);
        }
    }
}
